﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.MODE;
using EnvironmentManagerSystem.Utility;
using AjaxPro;
using System.IO;
using System.Text;
using System.Drawing;

namespace EnvironmentManagerSystem.ExpertManager
{
    public partial class NewExperts : System.Web.UI.Page
    {
        public string ImageURL
        {
            get
            {
                if (ViewState["ImageURL"] == null)
                {
                    ViewState["ImageURL"] = string.Empty;
                }
                return ViewState["ImageURL"].ToString();
            }
            set
            {
                ViewState["ImageURL"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                txtBind();
                DataBind();
            }
        }

        #region 绑定文本框
        public string id;
        public void txtBind()
        {
            id = Request.QueryString["id"];
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {
                ExpertData model = Expert.GetModelByID(id)[0];
                txtBirthday.Text = model.Birthday.Trim();
                txtCertNo.Text = model.CardNo.Trim();
                txtCompany.Text = model.Work.Trim();
                txtEMail.Text = model.Email.Trim();
                txtExpertName.Text = model.Name.Trim();
                txtFax.Text = model.Fax.Trim();
                txtMobile.Text = model.Mobile.Trim();
                txtNowCompany.Text = model.NowWork.Trim();
                txtPhone.Text = model.Phone.Trim();
                txtRecommendation.Text = model.Recommendation.Trim();
                if (model.Sex == "男")
                    rbNan.Checked = true;
                else if (model.Sex == "女")
                    rbNv.Checked = true;
                txtTitle.Text = model.Title.Trim();
                TextBox1.Text = model.ExpertMemo.Trim();
                txtBusinessType.Text = model.BusinessType.Trim();
                txtEIAType.Text = model.EIAType.Trim();
                if (model.ImageURL == "")
                    Image1.ImageUrl = "~/NewsImages/images/zhuanjia.png";
                else
                {
                    Image1.ImageUrl = model.ImageURL;
                    ImageURL = model.ImageURL.Replace("\\", "\\\\");
                }
                if (model.ExpertType == "行业专家")
                    cbExpertType1.Checked = true;
                else if (model.ExpertType == "环评专家")
                    cbExpertType2.Checked = true;
                else if (model.ExpertType == "行业专家,环评专家")
                {
                    cbExpertType1.Checked = true;
                    cbExpertType2.Checked = true;
                }
            }
        }
        #endregion

        #region 行业类别，环评类别绑定
        public void DataBind()
        {
            //行业类别
            DataTable ccc = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("14", "%");
            IndustryType1.DataSource = ccc;
            IndustryType1.DataBind();
            IndustryType1.Items.Insert(0, new ListItem("请选择", "0%"));
            //环评类别
            DataTable cccccc = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("7");
            ddlEIAType.DataSource = cccccc;
            ddlEIAType.DataBind();
            ddlEIAType.Items.Insert(0, new ListItem("请选择", "0"));
        }
        protected void tbs001_developprojectbasicinfo_IndustryType1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //行业类别2
            IndustryType2.DataSource = EnvironmentManagerSystem.BLL.ConstructionUnit.Gethylb("24", IndustryType1.SelectedValue + "%");
            IndustryType2.DataBind();
        }
        #endregion
    }
}